from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
admin.autodiscover()

# def default(request):
#     from django.http import HttpResponse
#     return HttpResponse('<h1>Default index page</h1> Visit <a href="display/">display</a> subpage.')

from entelib.news.models import News

# see: http://docs.djangoproject.com/en/dev/ref/generic-views/

urlpatterns = patterns(
    '',
    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/', include(admin.site.urls)),

    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes':True}),

    (r'^display/$', 'entelib.display.views.index'),
    (r'^display/(?P<i>\d+)$', 'entelib.display.views.show_detailed'),

    # (r'^404/', 'django.views.generic.simple.', 'direct_to_template', {'template': '404.html'}),
    # (r'^500/', 'django.views.generic.simple.', 'direct_to_template', {'template': '500.html'}),

    (r'^news/create/?$', 'django.views.generic.create_update.create_object', dict(model=News, template_name='news/create.html',  post_save_redirect="/news/") ),
    (r'^news/update/(?P<object_id>\d+)$', 'django.views.generic.create_update.update_object', dict(model=News, template_name='news/update.html', post_save_redirect="/news/") ),
    (r'^news/?$', 'django.views.generic.list_detail.object_list', {'queryset':News.objects.all().order_by('-id'), 'paginate_by':3, 'allow_empty':True, 'template_name':'news/list.html'}),
    (r'^news/edit/(?P<object_id>\d+)$', 'entelib.news.views.edit_news'),
    # (r'^news/edit/(?P<object_id>\d+)$', 'entelib.urls.edit_news'),

    # (r'', 'entelib.urls.default'),
)
